Skip to content

Split icons to separate files for ESM tree-shaking#8

Merged
RaresAil merged 7 commits intoRaresAil:mainfrom
t3rminus:esm-tree-shaking
Apr 12, 2026
Merged

Split icons to separate files for ESM tree-shaking#8
RaresAil merged 7 commits intoRaresAil:mainfrom
t3rminus:esm-tree-shaking

Conversation

@t3rminus
Copy link
Copy Markdown
Contributor

@t3rminus t3rminus commented Jan 20, 2026

This PR splits up the icons into separate files in the ESM version of the build to allow for efficient tree-shaking when creating application bundles. Unused icons will be pruned from the final bundle dramatically reducing file size and loading time.

Before:
./node_modules/@raresail/react-ionicons/dist/esm/index.js (1.11 MB)

After:
./static/chunks/*.js (Count: 289)
Total size: 440.2 KB

@RaresAil RaresAil requested review from RaresAil and Copilot January 21, 2026 06:26
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR restructures the build output to enable ESM tree-shaking by splitting individual icon components into separate files, reducing bundle sizes from 1.11 MB to 440.2 KB when only specific icons are imported.

Changes:

  • Modified Rollup configuration to generate separate files for each icon in the ESM build
  • Added post-build processing to conditionally re-add strokeWidth parameter only to icons that use it
  • Updated package.json with sideEffects field to support tree-shaking optimization

Reviewed changes

Copilot reviewed 4 out of 6 changed files in this pull request and generated 3 comments.

File Description
rollup.config.js Reconfigured ESM output to use multiple entry points (one per icon file) instead of a single bundle
post-build-icons.js Added logic to selectively restore strokeWidth parameter to icon components that reference it
templates/svg.js Removed strokeWidth from default function parameters (restored conditionally in post-build)
package.json Added glob dependency, sideEffects configuration, and changed yarn to npm in build script

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@RaresAil RaresAil merged commit 9762cac into RaresAil:main Apr 12, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants